package probes.conexioBD;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.swing.JOptionPane;

public class Connexio {
	
	private String incorrectConection ="Error al establecer la conexion con la base de datos";
	private String titleIncorrectCon = "Error de conexion";
	
	private String errorDriver = "Error al iontentar conectar con el driver MySQL";
	private String titleDriver = "Error Driver";
	
	
	public Connection conexioBD(){
		Connection con = null;
		
		try{
			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ALMACEN_ELECTRICA_ALBERTI","root","78217369-E");
			
		}catch(SQLException e){
			JOptionPane.showMessageDialog(null, incorrectConection, titleIncorrectCon, JOptionPane.ERROR_MESSAGE);
		}catch(ClassNotFoundException e){
			JOptionPane.showMessageDialog(null, errorDriver, titleDriver, JOptionPane.ERROR_MESSAGE);
		}
		
		return con;
	}

}
